package com.buba.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import entity.maintenance.MaintenanceExperience;
import com.buba.mapper.MaintenanceExperienceMapper;
import com.buba.service.MaintenanceExperienceService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import entity.maintenance.MaintenanceLevel;
import entity.maintenance.dto.MaintenanceExperienceDto;
import entity.maintenance.dto.MaintenanceExperienceQueryWrapper;
import entity.maintenance.dto.MaintenanceLevelQueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import utils.pageutil.MyPageHelper;
import utils.pageutil.PageRequest;
import utils.pageutil.PageResult;

import java.util.List;

/**
 * <p>
 * 保养经验 服务实现类
 * </p>
 *
 * @author beisheng
 * @since 2023-05-18
 */
@Service
public class MaintenanceExperienceServiceImpl extends ServiceImpl<MaintenanceExperienceMapper, MaintenanceExperience> implements MaintenanceExperienceService {

   @Autowired
    private MaintenanceExperienceMapper maintenanceExperienceMapper;

    /**
     * @return common.R
     * @Author atlong
     * @Description 模糊分页全查保养经验数据
     * @Date 2023/6/14 14:46
     * @Param [maintenanceExperienceDto]
     **/
    @Override
    public PageResult selMaintenanceExperience(MaintenanceExperienceDto maintenanceExperienceDto) {
        //创建模糊查数据对象
        MaintenanceExperienceQueryWrapper maintenanceExperienceQueryWrapper = new MaintenanceExperienceQueryWrapper();
       // 调用封装的queryWrapper模糊查方法
        QueryWrapper<MaintenanceExperience> conditional = maintenanceExperienceQueryWrapper.conditional(maintenanceExperienceDto);
        //分页
        PageRequest pageRequest = new PageRequest(maintenanceExperienceDto.getPage(), maintenanceExperienceDto.getPageSize());
        MyPageHelper.startPage(pageRequest);
        List<MaintenanceExperience> list = maintenanceExperienceMapper.selectList(conditional);
        PageResult pageResult = MyPageHelper.getPageResult(list);
        return pageResult;
    }
}
